package com.zhengsr.wanandroid;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.airbnb.lottie.LottieAnimationView;
import com.zhengsr.CoreManager;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SplashActivity extends AppCompatActivity {
    private static final String TAG = "SplashActivity";
    @BindView(R.id.lottie_ww)
    LottieAnimationView mLottieView_ww;
    @BindView(R.id.lottie_aa)
    LottieAnimationView mLottieView_AA;
    @BindView(R.id.lottie_nn)
    LottieAnimationView mLottieView_NN;
    @BindView(R.id.lottie_a)
    LottieAnimationView mLottieView_A;
    @BindView(R.id.lottie_n)
    LottieAnimationView mLottieView_N;
    @BindView(R.id.lottie_d)
    LottieAnimationView mLottieView_D;
    @BindView(R.id.lottie_r)
    LottieAnimationView mLottieView_R;
    @BindView(R.id.lottie_o)
    LottieAnimationView mLottieView_O;
    @BindView(R.id.lottie_i)
    LottieAnimationView mLottieView_I;
    @BindView(R.id.lottie_dd)
    LottieAnimationView mLottieView_DD;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);

        startAnim();

        //只是模拟，就不要引导图，5s等乱七八糟的东西了，直接延时进入，简单粗暴

        CoreManager.getHandler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(SplashActivity.this
                        ,MainActivity.class));
                finish();
            }
        },2000);


    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    private void startAnim(){
        playAnim(mLottieView_ww,"W.json");
        playAnim(mLottieView_AA,"A.json");
        playAnim(mLottieView_NN,"N.json");
        playAnim(mLottieView_A,"A.json");
        playAnim(mLottieView_N,"N.json");
        playAnim(mLottieView_D,"D.json");
        playAnim(mLottieView_R,"R.json");
        playAnim(mLottieView_O,"O.json");
        playAnim(mLottieView_I,"I.json");
        playAnim(mLottieView_DD,"D.json");
    }


    private void playAnim(LottieAnimationView view,String animationName) {
        if (view != null) {
            view.setAnimation(animationName);
            view.playAnimation();
        }
    }
}
